package com.hzcrash.tools;

import java.io.File;
import java.io.IOException;

import android.os.Environment;
import android.util.Log;

public class HBLog {
	private final static String TAG = "beauty";
	private final static String FILE_NAME = "handbbv5.log";
	private static boolean showLog = true;
	
	public static void ShowLog(boolean bShow){
		showLog = bShow;
	}
	
	public static void i(String subTag, String content){
		if ( showLog )
			Log.i(TAG, subTag + "->" + content);
	}
	
	public static void i(String content){
		if ( showLog )
			Log.i(TAG, content);
	}
	
	public static void d(String subTag, String content){
		if ( showLog )
			Log.d(TAG, subTag + "->" + content);
	}
	
	public static void d(String content){
		if ( showLog )
			Log.d(TAG, content);
	}
	
	public static void w(String subTag, String content){
		if ( showLog )
			Log.w(TAG, subTag + "->" + content);
	}
	
	public static void w(String subTag, String content, Throwable tr){
		if ( showLog )
			Log.w(TAG, subTag + "->" + content, tr);
	}
	
	public static void w(String content){
		if ( showLog )
			Log.w(TAG, content);
	}	
	
	public static void w(String content, Throwable tr){
		if ( showLog )
			Log.w(TAG, content, tr);
	}
	
	public static void e(String subTag, String content){
		if ( showLog )
			Log.e(TAG, subTag + "->" + content);
	}
	
	public static void e(String subTag, String content, Throwable tr){
		if ( showLog )
			Log.e(TAG, subTag + "->" + content, tr);
	}	
	
	public static void e(String content){
		if ( showLog )
			Log.e(TAG, content);
	}

	public static void e(String content, Throwable tr){
		if ( showLog )
			Log.e(TAG, content, tr);
	}	
	
	public static void v(String subTag, String content){
		if ( showLog )
			Log.v(TAG, subTag + "->" + content);
	}
	
	public static void v(String content){
		if ( showLog )
			Log.v(TAG, content);
	}
	
	public static void Save(){
		try {
			File filename = new File( Environment.getExternalStorageDirectory() + FILE_NAME );
			filename.createNewFile();      
			String cmd = "logcat -d -f " + filename.getAbsolutePath();     
			Runtime.getRuntime().exec(cmd); 
		} catch (IOException e) {     
			e.printStackTrace(); 
		} 		
	}
}
